#ifndef XSERVO_H
#define XSERVO_H

#include <QTimer>
#include "ServoDrive.h"
#include "EthercatMaster.h"

// 兼容ServoWin的通讯协议帧
typedef struct
{
    uint16_t head;
    uint16_t func;
    uint16_t len;
    uint16_t buf[29];
}servo_win_frame_s;



class xServo : public ECatDrv::ServoDrive
{
public:
    xServo();

    xServo(unsigned int eep_man, unsigned int eep_id, const std::string& slave_name, int slave_addr,
           ECatDrv::slaveType slave_type);

    void initPdoOutput();

    void initPdoInput();

    int configurePDO();

    void CommuFrame(uint16_t* send, uint16_t* recv);

    void JogOn(int vel);

    bool ServoJog(int dir, uint16_t head,int vel);

    void JogOff();

    void StMachineUpdate();

#ifdef xServo_SDO_CONTROL
    bool ServoEnable();

    void ServoDisable();

#endif
    ECatDrv::xServoPDOOutput* servo_output;
    ECatDrv::xServoPDOInput* servo_input;
};

#endif // XSERVO_H
